package com.lmx.project.service.iml;

import com.lmx.project.service.FileService;
import com.lmx.project.until.FileUtil;
import com.lmx.project.until.FileUtilAsync;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;


/**
 * 资源实现类
 */
//@DubboService
@Service
public class FileServiceIml implements FileService {

    @Resource
    private FileUtil fileUtil;

    @Resource
    private FileUtilAsync fileUtilAsync;

    @Override
    public String printstring() {
        return "2323";
    }

    @Override
    public void saveFileFromInputStream(InputStream inputStream, String path) throws IOException {
//        fileUtil.((MultipartFile) inputStream,path);
        fileUtil.saveFileFromInputStream(inputStream, path);
    }

    @Override
    public void moveFile(String oldpath, String newpath) throws IOException {
        fileUtil.moveFile(oldpath, newpath);
    }

    @Override
    public String getFilename(MultipartFile image) {
        return fileUtil.getFilename(image);
    }

    @Override
    public String getPreurl() {
        return fileUtil.getPreurl();
//        return null;
    }

    @Override
    public void removeFileList(List<String> collect) {
        fileUtil.removeFileList(collect);
    }

    @Override
    public boolean isImage(InputStream inputStream) throws IOException {
        return fileUtil.isImage(inputStream);
    }

    @Override
    public boolean isVideo(InputStream inputStream) throws IOException {
        return fileUtil.isVideo(inputStream);
    }

    @Override
    public boolean isVideoFileByFilename(String fileName) {

        return fileUtil.isVideoFileByFilename(fileName);
    }

    @Override
    public String saveMultipartFile(MultipartFile file, String dir) {
        return fileUtil.saveMultipartFile(file, dir);
    }

    @Override
    public void removeFile(String path) {
        fileUtil.removeFile(path);
    }

    @Override
    public void saveFile(InputStream inputStream, String absolutePath) throws IOException {
        fileUtil.saveFile(inputStream, absolutePath);
    }

    @Override
    public String getPre() {
        return fileUtil.getPreurl();
    }
}
